<template>
  <div>
    <h1>文章列表</h1>
    <ul>
      <li v-for="item in newsList" :key="item.id">{{ item.title }}</li>
    </ul>
  </div>
</template>
<script>
import { getNewsList } from "../../utils/home.js";
import { reactive, toRefs, ref } from "vue";
export default {
  setup() {
    const data = reactive({
      newsList: [],
    });

    getNewsList().then((res) => {
      data.newsList = res.data;
    });
    //获取 文章列表 渲染数据
    return { ...toRefs(data) };
  },
};
</script>
